<template>
	<view>
		<view>云储存</view>
		<button @click="upload">上传图片</button>
		<button @click="download">下载图片</button>
	</view>
</template>

<script setup>
	const upload = () => {
		uni.chooseImage({
			count: 6, //默认9
			sizeType: ['original', 'compressed'],
			sourceType: ['album'],
			success: function({
				tempFilePaths
			}) {
				tempFilePaths.forEach(filePath => {
					console.log('文件地址', filePath);
					uniCloud.uploadFile({
						filePath,
						cloudPath: 'a.jpg',
						success: () => {
							uni.showToast({
								title: '上传成功',
								icon: 'success'
							})
						}
					})
				})
			}
		});
	}

	const download = async () => {
		const {
			fileList
		} = await uniCloud.getTempFileURL({
			fileList: ["5867391b-ef96-4f03-aad5-01ac13d0c7a0"],
		});
		await uni.saveImageToPhotosAlbum({
			filePath: fileList[0].tempFileURL
		})
	}
</script>

<style>

</style>